﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PilotProject;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var context = new PilotEntities1();
            //var testEngine = context.TestEngines.ToList();
            //var states = context.States.ToList();

            //var suburb = states.First().Suburbs.First(); 
            //var candidateAddress = new Address { Suburb = suburb, Street1 = "14 Henry lane" };

            //var candiate = new Candidate { Address = candidateAddress, ARN = "WIlliam' ARN", FirstName = "WIlliamb", LastName = "Smith", Telephone = "98544654", Email = "bob@email.com", IsActive = true };

            //var examinerAddress = new Address { Suburb = suburb, Street1 = "13 Henry lane" };
            //var examiner = new Examiner{ Address = candidateAddress, ARN = " freds' ARN", FirstName = "fred", LastName = "Smith", Telephone = "98544655", Email = "fred@email.com", IsActive = true };

            //context.AddObject("People", candiate);
            //context.AddObject("People", examiner); 

            //var testEngine = context.TestEngines.First();
            //var token = context.TestTokens.First();

            //var test = context.Tests.First();

            //test.ActivateTest();

            var candidate = context.People.OfType<Candidate>().First();
            var examiner = context.People.OfType<Examiner>().First();


            var pilotTestEngine = context.TestEngines.OfType<JumpPilotTestEngine>().First();
            var token = pilotTestEngine.GenerateTestToken(candidate, examiner);
            //Console.WriteLine(token.Id);

            //context.SaveChanges();
            //Console.WriteLine(token.Id);

            //var t = context.TestTokens.ToList()[2];
            var x = token.GenerateTest();
            var test = token.Test;
            var testQuestions = test.TestQuestions.ToList(); 
            //t.TestEngine.LoadQuestions(x);

            context.SaveChanges();
            //Console.WriteLine(x.TestQuestions.Count);


            //int i = 0; 

            //context.SaveChanges();  
         
        }
    }
}
